package com.hubiao.basics.pattern.observice;

/**
 * Created by jackhu on 2019/3/17.
 */
public class ObserverTest {

    public static void main(String[] args) {
        //实例化被观察者
        GPer gper = GPer.getInstance();

        //实例化观察者
        Teacher jackhu = new Teacher( "jackhu" );
        Teacher mic = new Teacher( "Mic" );


        //这是发起的问题
        Question question = new Question();
        question.setUserName( "小明" );
        question.setContent( "观察者设计模式适用于哪些场景？" );

        // 被观察者添加观察者
        gper.addObserver( jackhu );
        gper.addObserver( mic );

        //调用自定义的发送方法
        gper.publishQuestion( question );
    }
}
